#ifndef API_H
#define API_H

#include <QMainWindow>
#include <QtNetwork>
#include <QDebug>
#include <QString>
#include <QVariant>
#include <QHttpMultiPart>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QDialog>
#include <Utils.h>

class Api : public QObject
{
    Q_OBJECT
public:
    explicit Api(QObject *parent = nullptr);

    QNetworkReply* login(QString username,QString pwd);
    //获取首页菜单
    QNetworkReply* getRouters();
    //个人信息
    QNetworkReply* getInfo();
    //登出
    QNetworkReply* logout();
    //个人信息
    QNetworkReply* profile();
    //上传头像
    QNetworkReply* uploadAvatar(QString filePath);
    //更新个人信息
    QNetworkReply* updateUser(User *user);
    //修改密码
    QNetworkReply* updatePwd(QString oldPwd,QString newPwd);


public slots:
    void replyFinished(QNetworkReply *reply);

private:
    QString baseUrl ;
    QNetworkRequest request;
    QNetworkAccessManager *manager ;
    QVariant v ;

};

#endif // API_H
